function addcaseinfo(){
    $.post("/api/case/addcaseinfo",{
        casename:$("#newcasename").val(),
        caseinfo:$("#newcaseinfo").val(),
        projectid:$("#caseprojectid").val()
    },function (data){
            addresponse(data)
        }
    )
}


function getcaseinfo(caseid){
    $.get("/api/case/getcaseinfo",{
        caseid:caseid
    },function (data){
        addupdatainfo(data)
        }
    )
}

function upcaseinfo(){
    $.post("/api/case/upcaseinfo",{
        caseid:$("#caseidinfo").html(),
        casename:$("#newcasename").val(),
        caseinfo:$("#newcaseinfo").val()
    },function (data){
        addresponse(data)
        }
    )
}

function goaddupcaseinfo(){
    var caseid=$("#caseidinfo").html();
    console.log("---->>>>>>>"+caseid)
    if(!caseid){
        addcaseinfo();
    }
    else {
        upcaseinfo();
    }
}

function delcasemodel(caseid){
    $("#delinterinfoModal").modal('show');
    $("#delcaseidmodel").html(caseid);
}

function delcaseinfo(){
    $.get("/api/case/del",{
        caseid: $("#delcaseidmodel").html()
    },function (data){
        getinterinfomodeltype(data)
        }
    )
}

function addclearcaseinfo(){
    $("#newcasename").val('');
    $("#newcaseinfo").val('');
    $("#caseidinfo").html('');
    $('#addcaseinfomodel').modal('show');
}

function displaynone(info){
    document.getElementById(info).style.display="none";
}

function refresh(){
    window.location.reload();
}
function addresponse(data){
    if(data.code != 0){
        var messages=data.message;
        document.getElementById("casemessage").innerHTML=messages;
        document.getElementById("casemessage").style.display="";
        setTimeout('displaynone(\'casemessage\')',2000)
    }
    else{
        var messages="保存成功";
        document.getElementById("casemessage").innerHTML=messages;
        document.getElementById("casemessage").style.display="";
        setTimeout('refresh()',1500);
    }
}

function addupdatainfo(data){
    if(data.code!=0){
        document.getElementById("casemessage").innerHTML=messages;
        document.getElementById("casemessage").style.display="";
        setTimeout('displaynone(\'casemessage\')',2000)
    }
    else {
        $("#newcasename").val(data.data.casename);
        $("#newcaseinfo").val(data.data.caseinfo);
        $("#caseidinfo").html(data.data.caseid);
    }
    $('#addcaseinfomodel').modal('show');
}